/*
 * @Author: suxunying
 * @desc: user reducer
 * @Date: 2021-07-22 14:13:45
 * @LastEditors: suxunying
 * @LastEditTime: 2021-07-26 10:23:43
 * @FilePath: \bmp-poc\plat\src\shared\modules\user\reducer.ts
 */
interface UserInfo {
    username: string,
}

interface State {
    userinfo?: UserInfo | Record<string, never>
}

const state:State = {
    userinfo: {},
};

type Mutation = {
    type: string;
    payload: any;
}

const reducer = (userState: State = state, mutation: Mutation): State => {
    switch (mutation.type) {
    case 'SET_USERINFO': return {
        ...userState,
        userinfo: mutation.payload,
    }; break;
    default: return userState;
    }
};

export default reducer;
